#ifndef SIMPLEAUTOMATICSEGMENTATION_H
#define SIMPLEAUTOMATICSEGMENTATION_H

#include "AmaranthusCommon.h"

#include "itkConnectedThresholdImageFilter.h"
//#include "itkConnectedComponentImageFilter.h"
#include "itkBinaryImageToLabelMapFilter.h"
#include "itkLabelMap.h"
#include "itkLabelObject.h"
#include "itkAttributeLabelObject.h"

#include "vtkSmartPointer.h"

#include <QString>
#include <QList>
#include <QPolygonF>
//#include "qwt_spline.h"

class SimpleAutomaticSegmentation
{

public:
    typedef itk::ConnectedThresholdImageFilter<GreyImageType, BinaryImageType> ConnectedFilterType;
    typedef typename ConnectedFilterType::Pointer ConnectedFilterPointer;

    typedef GreyImageType::IndexType PixelType;

    typedef itk::BinaryImageToLabelMapFilter<BinaryImageType> BinaryToLabelFilterType;
    typedef BinaryToLabelFilterType::Pointer BinaryToLabelFilterPointer;

    SimpleAutomaticSegmentation(Material* material);
    ~SimpleAutomaticSegmentation();

    void Initialize(GreyImagePointer image, double x, double y, double z);

    LabelMapPointer GetOutput()
    { return m_LabelMap; }

private:
    GreyImageType& DoSegmentation();

    bool m_Initialized;
    GreyImageType::PointType m_WorldSeed;
    GreyImageType::IndexType m_IndexSeed;

    GreyImagePointer m_InputImage;
    LabelMapPointer m_LabelMap;
    ConnectedFilterPointer m_ConnectedFilter;
    BinaryToLabelFilterPointer m_BinaryToLabelFilter;

    Material* m_Material;
};

#endif
